(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
"use strict";

loader.define(['pages/config/config'], function (config, require, exports, module, global) {
  var pageview = {};

  pageview.init = function () {
    var data;
    var getParams = bui.getPageParams();
    getParams.done(function (result) {
      console.log(result);
      data = result['data'];
    });
    console.log(data['photo']);
    var userInput = bui.input({
      id: ".user-input",
      callback: function callback(e) {
        // 清空数据
        this.empty();
      }
    }); // 密码不能为空

    var haspwd = function haspwd(pwd) {
      if (pwd == '') return false;
      return true;
    }; // 注册的时候校验只能由8-18位字母或者数字.@_组成


    var pwdcheck = function pwdcheck(pwd) {
      var rule = /^[a-zA-Z0-9.@_]{8,18}$/;

      if (!rule.test(pwd)) {
        return false;
      }

      return true;
    }; // 两次密码相等


    var pwdconfirm = function pwdconfirm(pwd1, pwd2) {
      if (pwd1 != pwd2) return false;
      return true;
    }; // 密码显示或者隐藏


    var password = bui.input({
      id: "#weixinPwdInput",
      iconClass: ".icon-eye",
      onBlur: function onBlur(e) {
        if (!haspwd(e.target.value)) {
          bui.hint("密码不能为空");
        } else if (!pwdcheck(e.target.value)) {
          bui.hint("密码只能由8-18位字母或者数字.@_组成");
        }

        ;
      },
      callback: function callback(e) {
        //切换类型
        this.toggleType(); //

        $(e.target).toggleClass("active");
      }
    });
    $("#btn-weixin-register").on("click", function (e) {
      var mobile = $("#weixinPhonenumber").attr("value");
      var password = $("#weixinPassword").attr("value");
      var password2 = $("#weixinConfirmpwd").attr("value");

      if (!pwdconfirm(password, password2)) {
        bui.hint("两次密码不一致");
        return;
      }

      if (mobile == '') {
        bui.hint("请填写手机号");
        return;
      }

      if (!haspwd(password) || !pwdcheck(password) || !pwdconfirm(password, password2)) {
        bui.hint("注册失败,请检查密码输入"); // 清空数据

        $("#password").val("");
        $("#confirmpwd").val("");
      } else {
        var data_ = {
          phone: mobile,
          pwd: password,
          openid: data['openid'],
          photo: data['photo']
        };
        data_ = JSON.stringify(data_);
        bui.ajax({
          // url: 相对路径
          url: config.apiurl + "api/v1.0/phonefornew",
          data: data_,
          method: "post",
          headers: {
            'Content-Type': 'application/json'
          }
        }).then(function (result) {
          console.log(result.ans);
          if (result.ans == 0) bui.hint("该手机号已被注册");else if (result.ans == 2) {
            bui.hint("现为您转到个人信息填写界面");
            var personlocation = "";
            bui.load({
              url: "pages/registercontent/registercontent",
              param: {
                flag: "1",
                personlocation: personlocation
              }
            });
          }
        }, function (res, status) {
          console.log("www");
          console.log(status);
        });
      }
    });
  };

  pageview.init();
  return pageview;
});
},{}]},{},[1]);
